# -*- encoding:utf-8 -*-
# @time:2022-11-16 21:11
# @Author : serein
# @Email: serein@qq.com
# @File:modelsMixin.py
# @Software: PyCharm

from django.db import models

class DataTimeModelsMixin(models.Model):
    '''时间创建'''
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更改时间')
    class Meta:
        abstract = True #指定该类为抽象类，在迁移映射的时候不会生成对应表
class ISDeleteModelsMixin(models.Model):
    '''逻辑删除'''
    is_delete = models.BooleanField(default=False,verbose_name='逻辑删除')
    def delete(self, using=None, keep_parents=False):
        self.is_delete = True
        self.save()
    class Meta:
        abstract = True
class ModelSetMixin(DataTimeModelsMixin,ISDeleteModelsMixin):
    class Meta:
        abstract = True
    """模型扩展类整合"""